<?php

/*
 * File  : produk.php
 * Table : produks, kategoris
 */
//session_start();
//cek session

if ((!$_SESSION["USRID"] AND !$_SESSION["USRPASS"])) {
    header("location: ../index.php");
    exit();
}
//end
?>
<?php

$aksi = "bab/m_laporan/print.php";
switch ($_GET["opr"]) {

    default :
        echo "<h2>Laporan</h2>
          <form method=POST action='?module=report&opr=rep'>";
        echo ' <table>
          <tr><td>From</td><td> : ';
        combotgl(1, 31, 'tgl_mulai', $tgl_sekarang);
        combonamabln(1, 12, 'bln_mulai', $bln_sekarang);
        combothn(2000, $thn_sekarang, 'thn_mulai', $thn_sekarang);
//<form method=POST action='" . URLHOST . "$aksi?module=report&opr=getreport'>

        echo "</td></tr>
          <tr><td>To</td><td> : ";
        combotgl(1, 31, 'tgl_selesai', $tgl_sekarang);
        combonamabln(1, 12, 'bln_selesai', $bln_sekarang);
        combothn(2000, $thn_sekarang, 'thn_selesai', $thn_sekarang);

        echo "</td></tr>";
        echo "  <tr><td>Status Transaksi</td>  <td> :";
        echo "   <select name='in_status'>";
        $tampil = mysql_query("SELECT * FROM status ORDER BY status_id");
        echo "<option value ='%'>All</option>";
        while ($w = mysql_fetch_array($tampil)) {

            echo "<option value ='" . $w["status_id"] . "'>" . $w["status_nama"] . "</option>";
        }
        echo"</select>";

        echo "<tr><td colspan=2><input type=submit value=Proses>
         </td></tr>
          </table>
          </form>";
        break;

    case "rep":
        $mulai = $_POST[thn_mulai] . '-' . $_POST[bln_mulai] . '-' . $_POST[tgl_mulai];
        $selesai = $_POST[thn_selesai] . '-' . $_POST[bln_selesai] . '-' . $_POST[tgl_selesai];
        $status = $_POST[in_status];
		$details = $_POST[in_detail];
        $m = $_POST[tgl_mulai] . '-' . $_POST[bln_mulai] . '-' . $_POST[thn_mulai];
        $s = $_POST[tgl_selesai] . '-' . $_POST[bln_selesai] . '-' . $_POST[thn_selesai];

        echo "<p></br></p>";
       // echo "<form method=POST>";
        echo " <table>";
        echo " <h2>Laporan Transaksi Penjualan Online E-Rider</h2> ";
        echo "<h3>Periode $m s/d $s </h3><br/>";
        echo "  <tr><th>No</th><th>No.Nota</th><th>Tanggal Order</th><th>No. Resi</th><th>Konsumen</th><th>Telepon</th><th>Email</th><th>Status</th><th>Total</th></tr>";

        if ($_POST[in_status] == '%') {

            $tampil = mysql_query("SELECT tr_x.trx_kodeunik as NoNota,trx_waktu as tanggal,
                    trx_noresi,trx_nama ,trx_notelp, trx_email,trx_status, trx_total
                    FROM tr_x
                    where date(trx_waktu) BETWEEN  '$mulai' AND '$selesai' and trx_status like '%' order by trx_waktu desc ");
        } else {
            $tampil = mysql_query("SELECT tr_x.trx_kodeunik as NoNota,trx_waktu as tanggal,
                    trx_noresi,trx_nama ,trx_notelp, trx_email,trx_status, trx_total
                    FROM tr_x
                    where date(trx_waktu) BETWEEN  '$mulai' AND '$selesai' and trx_status='$status' order by trx_waktu desc ");
        }
        $no = 1;
        while ($row = mysql_fetch_array($tampil)) {

            $harga = format_rupiah($row["trx_total"]);
            echo "<tr><td>$no</td>";
            echo " <td align=center>" . $row["NoNota"] . "</td>";
            echo " <td>" . $row["tanggal"] . "</td>";
            echo " <td align=center>" . $row["trx_noresi"] . "</td>";
            echo " <td>" . $row["trx_nama"] . "</td>";
            echo " <td>" . $row["trx_notelp"] . "</td>";
            echo " <td>" . $row["trx_email"] . "</td>";
            echo " <td align=center>" . get_status_transaksi($row["trx_status"]) . "</td>";
            echo " <td align=right>" . $harga . "</td>";

            echo " </tr>";
            $no++;
        }
		   echo '<script type="text/javascript">';
        //echo ' <!--';
        echo ' function popup() {';
        echo ' window.open( "' . URLPRINT . $mulai . "&edate=" . $selesai . "&stat=" . $status . '", "myWindow", ';
        echo ' \'height=600,width=700,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,titlebar=no\' )';
        echo ' }';
        //echo ' //-->';
        echo ' </script>';

        echo "<tr><td colspan=9><input type=submit value='To Print Version' onClick='popup()'/> <input type ='button' value ='Batal' onclick = self.history.back()></td></table>";
       // echo "</form>";
		
		
}
?>
